<template>
  <!-- :style="{ width: tdStyle.width, fontSize: tdStyle['font-size'] }" -->
  <div>
    <el-input
      class="form-input"
      :style="{ fontSize: tdStyle['font-size'] }"
      ref="input"
      type="text"
      resize
      :autofocus="false"
      v-model="value"
      @input="handleChange"
      @blur="handleBlur"
    ></el-input>
  </div>
</template>

<script>
export default {
  props: {
    value: {
      type: String,
      default: ''
    },
    tdStyle: {}
  },
  data() {
    return {
      x: 0,
      y: 0
    };
  },
  methods: {
    handleFocus(x, y) {
      this.x = x;
      this.y = y;
      this.$refs.input.focus();
    },
    handleBlur() {
      // this.$refs.input.blur();
    },
    handleChange(value) {
      console.log(value, 'value');
      this.$emit('input', {
        value,
        x: this.x,
        y: this.y
      });
      // this.$refs.input.blur();
    }
  }
};
</script>

<style lang="scss" scoped>
.form-input {
  width: 100%;
  height: 100%;
  position: absolute;
  box-sizing: border-box;
  top: 0;
  left: 0;
  border: none;

  ::v-deep .el-input__inner {
    height: 100%;
    line-height: 100%;
    border-radius: 0;
    text-align: center;
    &:focus {
      border-color: transparent;
    }
  }
}
</style>
